var e = getApp(), t = {
    clickTypeFun: function(t) {
        var a = this, i = a.data.searchobj;
        i.house_type = t.currentTarget.dataset.id, a.setData({
            searchobj: i,
            bangongtype: t.currentTarget.dataset.id
        });
        var s = a.data.house_is_register, r = a.data.house_house_type, d = a.data.tag, l = function(e, t) {
            for (var i = 0; i < e.length; i++) e[i].checked = "不限" === e[i].show;
            var s = {};
            s[t] = e, a.setData(s);
        };
        l(s, "house_is_register"), l(r, "house_house_type"), l(d, "tag");
        var o = a.data.searchobj;
        e.extend(o, {
            house_is_register: 0,
            house_house_type: "",
            tag: ""
        }), a.setData({
            searchobj: o
        });
    },
    clickTypeZX: function(e) {
        var t = this.data.searchobj;
        t.house_zhuangxiu = e.currentTarget.dataset.id, this.setData({
            searchobj: t,
            zhuangxiutype: e.currentTarget.dataset.id
        });
    },
    clickBrand: function(e) {
        var t = this.data.searchobj;
        t.saas_comp_id = e.currentTarget.dataset.id, this.setData({
            searchobj: t,
            saas_comp_id: e.currentTarget.dataset.id
        });
    },
    filterFun: function() {
        var e = this;
        setTimeout(function() {
            var t = e.data.house_is_register, a = e.data.house_house_type, i = e.data.tag, s = e.data.searchobj, r = function(e, t, a) {
                for (var i = [], s = 0; s < e.length; s++) if (e[s].checked) {
                    var r = e[s].val + "";
                    "undefined" === r && (r = !1), i.push(r || e[s].tag_id);
                }
                a[t] = i.join(",");
            };
            r(t, "house_is_register", s), r(a, "house_house_type", s), r(i, "tag", s), e.setData({
                searchobj: s
            });
        }, 200);
    },
    clickTypeTS: function(e) {
        for (var t = this, a = e.currentTarget.dataset, i = t.data[a.key], s = {}, r = 0; r < i.length; r++) {
            var d = i[r].tag_id || i[r].val;
            a.id == d && (s = i[r]);
        }
        s.checked = !s.checked;
        var l = {};
        l[a.key] = i, t.setData(l);
        var o = function(e, a) {
            for (var i = a, s = {}, r = 0; r < i.length; r++) "不限" !== (i[r].show || i[r].name) && (i[r].checked = !1);
            s[e] = i, t.setData(s);
        }, n = t.data.house_is_register;
        if ("house_is_register" === a.key && 0 == a.id) o("house_is_register", t.data.house_is_register), 
        o("house_house_type", t.data.house_house_type), o("tag", t.data.tag); else {
            for (var c = 0; c < n.length; c++) "不限" == n[c].show && (n[c].checked = !1);
            t.setData({
                house_is_register: n
            });
        }
    },
    clickTypeClear: function(e) {
        var t = this;
        t.setData({
            bangongtype: 0,
            zhuangxiutype: 0,
            brand: 0
        });
        var a = this.data.house_is_register, i = this.data.house_house_type, s = this.data.tag, r = function(e, a) {
            for (var i = 0; i < e.length; i++) e[i].checked = "不限" === e[i].show;
            var s = {};
            s[a] = e, t.setData(s);
        };
        r(a, "house_is_register"), r(i, "house_house_type"), r(s, "tag"), t.setData({
            searchobj: {
                house_type: 0,
                house_zhuangxiu: 0,
                house_is_register: 0,
                house_house_type: "",
                tag: ""
            }
        });
    },
    goTap: function(t) {
        var a = this, i = t.currentTarget.dataset;
        if (i.obj && (i = i.obj), void 0 === i.listorder) {
            var s = a.data.filter;
            void 0 !== i.price && (delete s.avg_price, a.setData({
                totleprice: i.totleprice,
                avgprice: "",
                filterPrice: ""
            })), void 0 !== i.avg_price && (delete s.price, a.setData({
                avgprice: i.avgprice,
                totleprice: "",
                filterPrice: ""
            })), e.extend(i, s, !0), 0 == i.val || 0 == i.lineid ? (delete i.id, delete i.station, 
            delete i.subway_line) : a.setData({
                filter: i
            }), 0 == a.data.filter.circle_id && 0 == i.lineid || 0 == a.data.filter.circle_id && 0 == i.station || 0 == a.data.filter.circle_id && i.station || 0 != a.data.filter.circle_id && 0 == i.lineid && a.data.filter.district_id || 0 != i.circle_id && 0 == i.station && i.district_id || i.circle_id && i.station && i.district_id ? 0 == a.data.filter.circle_id && 0 == i.lineid ? a.setData({
                filterPosition: a.data.districtname + "-" + i.subwayall
            }) : 0 == a.data.filter.circle_id && 0 == i.station ? a.setData({
                filterPosition: a.data.districtname + "-" + a.data.subwayline
            }) : 0 == a.data.filter.circle_id && 0 != i.station ? a.setData({
                filterPosition: a.data.districtname + "-" + i.subwayname
            }) : 0 != a.data.filter.circle_id && 0 == i.lineid && a.data.filter.district_id ? (delete i.subwayname, 
            delete a.data.filter.subway_line, delete a.data.filter.station, a.setData({
                filterPosition: a.data.districtname + "-" + i.circlename
            })) : 0 != i.circle_id && 0 == i.station ? a.setData({
                filterPosition: i.circlename + "-" + a.data.subwayline
            }) : 0 != i.circle_id && 0 != i.station && a.setData({
                filterPosition: i.circlename + "-" + i.subwayname
            }) : 0 == i.allval || 0 == i.circle_id || i.circle_id ? 0 == i.allval ? (delete i.subwayname, 
            delete a.data.filter.subway_line, delete a.data.filter.station, delete i.circlename, 
            delete i.district_id, delete i.circle_id, a.setData({
                filterPosition: i.allname
            })) : 0 == i.circle_id ? a.setData({
                filterPosition: a.data.districtname
            }) : 0 != i.circle_id && a.setData({
                filterPosition: a.data.districtname + "-" + i.circlename
            }) : (0 == i.lineid || 0 == i.station || i.station) && (0 == i.lineid ? (delete i.subwayname, 
            delete a.data.filter.subway_line, delete a.data.filter.station, delete i.circlename, 
            delete i.district_id, delete i.circle_id, a.setData({
                filterPosition: i.subwayall
            })) : 0 == i.station ? a.setData({
                filterPosition: a.data.subwayline
            }) : i.station && a.setData({
                filterPosition: a.data.subwayline + "-" + i.subwayname
            })), i.areas && a.setData({
                filterArea: i.areas
            });
        } else a.setData({
            order: i,
            ordertype: i.listorder
        });
        var r = e.getSecret(), d = e.extend({
            domain: e.globalData.domain,
            currtime: r.currtime,
            sign: r.sign,
            uuid: wx.getStorageSync("first_code")
        }, i);
        "0" === d.district_id && (delete d.district_id, delete d.circle_id), "0" === d.subway_line && (delete d.subway_line, 
        delete d.station), wx.request({
            url: e.globalData.haozuBase + "/api/miniapps/list/",
            data: d,
            success: function(t) {
                var s = t.data;
                if (0 != s.data.building_list.length) {
                    var r = e.extend(i, a.data.filter);
                    "0" === r.district_id && (delete r.district_id, delete r.circle_id), "0" === r.subway_line && (delete r.subway_line, 
                    delete r.station);
                    var l = s.data.building_list, o = l.items, n = [];
                    for (var c in o) o[c].point_name && (o[c].name = o[c].point_name), n.push(o[c]);
                    var u = {}, _ = [];
                    e.extend(_, a.data.areas), e.extend(u, a.data.tabArr), d.district_id || (u.curSdIndexR = -1, 
                    _ = []);
                    var h = [];
                    e.extend(h, a.data.stations), e.extend(u, a.data.tabArr), d.subway_line || (u.curLdIndexR = -1, 
                    h = []), "" == s.data.list_card.employee_info ? a.setData({
                        listProhide: !0
                    }) : a.setData({
                        listProhide: !1
                    }), a.setData({
                        building_items: n,
                        selected: 5,
                        nohouse: !1,
                        house_show: !0,
                        showDialog: !1,
                        pages: 1,
                        maxPage: Math.ceil(l.total / 10),
                        scrollTop: 0,
                        tabArr: u,
                        areas: _,
                        stations: h,
                        params: s.data.params,
                        buildCard: s.data.list_card.employee_info
                    });
                } else a.setData({
                    building_items: [],
                    nohouse: !0,
                    house_show: !1,
                    selected: 5,
                    showDialog: !1
                });
            }
        });
    },
    tabFun: function(e) {
        var t = Number(e.target.dataset.id), a = e.currentTarget.dataset.key, i = this.data.tabArr;
        i[a] = t, this.setData({
            tabArr: i
        });
    },
    tabFunlab: function(e) {
        var t = e.target.dataset.id, a = e.currentTarget.dataset.key, i = this.data.tabArr;
        i[a] = t, this.setData({
            tabArr: i
        });
    },
    showFn: function() {
        var e = this;
        wx.makePhoneCall({
            phoneNumber: e.data.msg_template
        });
    }
};

module.exports = t;